from .image_convert_base import ConvertBase
import numpy as np


class ConvertModel(object):
    
    def __init__(self, *args):
        
        self.converts = args
        
    
    def __convert_item(self, convert : ConvertBase, img, boxes, points):
        rate = convert.use_rate
        real = np.random.random()
        if real <= rate:
            return convert.convert(img, boxes, points)
        else:
            return img, boxes, points
    
    
    def convert(self, img, boxes, points):
        
        for convert in self.converts:
            img, boxes, points = self.__convert_item(convert, img, boxes, points)
            
        return img, boxes, points
        
                
    






